<template>
	<view>
		<view class="orderBox" v-for="(item,index) in dataList">
			<view class="orderTitle">
				<span class="one">{{index+1}}</span>
				<span class="two" @click="copyText(item.executeNo)">执行单号：{{item.executeNo}}</span>
				<span class="three">{{getOrderStatus(item.status)}}</span>
			</view>
			<view class="itemBox" @click="GotoDetail(item)">
				<view class="itemContent">
					<view class="itemTitle">执行服务项目:</view>
					<view class="itemValue">{{item.serviceProjectName||'--'}}</view>
				</view>
				<view class="itemContent">
					<view class="itemTitle">项目订单名称:</view>
					<view class="itemValue">{{item.projectName}}</view>
				</view>
				<view class="itemContent">
					<view class="itemTitle">项目订单编号:</view>
					<view class="itemValue">{{item.projectNo}}</view>
				</view>
				<view class="itemContent">
					<view class="itemTitle">业务运营方:</view>
					<view class="itemValue">{{item.providerName||'--'}}</view>
				</view>
				<view class="itemContent">
					<view class="itemTitle">创建时间:</view>
					<view class="itemValue">{{item.createTime||'--'}}</view>
				</view>
			</view>
			<view class="btnBox">
				<template v-if="item.status === 2">
					<view v-if="item.applyStatus == 2" @click="processing(item,'审核订单修改')" class="lookCompleted">
						审核订单修改
					</view>
					<view @click="processing(item,'申请完成')" class="lookCompleted">
						申请完成
					</view>
					<view @click="processing(item,'申请中止')" class="del">
						申请中止
					</view>
				</template>
				<view  v-if="[2, 3, 4].includes(item.status)" @click="processing(item,'工单管理')" class="lookCompleted">
					工单管理
				</view>
				<!-- <view v-if="item.applyStatus===2" @click="ReviewQuotations(item,'订单修改申请')" class="review">
					查看订单修改申请
				</view>
				<view v-if="item.orderApply&&Object.keys(item.orderApply).length&&item.orderApply.type===1"
					@click="processing(item,'订单完成申请')" class="lookCompleted">
					查看完成申请
				</view>
				<view v-if="item.orderApply&&Object.keys(item.orderApply).length&&item.orderApply.type===0"
					@click="processing(item,'订单关闭申请')" class="lookClose">
					查看关闭申请
				</view>
				<view v-if="item.status===0" @click="processing(item,'取消订单')" class="easy">
					取消订单
				</view>
				<view v-if="item.status===1" class="review" @click="ReviewQuotations(item,'订单确认')">
					订单确认
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		components: {},
		props: {
			dataList: {
				type: Array,
				default: () => {
					return [];
				},
			},
		},
		data() {
			return {
				modalshow: false,
				modalTilte: '',
				OrderStatusList: [
					{
						name: "待接单",
						value: 0
					},
					{
						name: "待变更",
						value: 1
					},
					{
						name: "已接单",
						value: 2
					},
					{
						name: "已完成",
						value: 3
					},
					{
						name: "已中止",
						value: 4
					},
				],
			}
		},
		methods: {
			copyText(text) {
				// 将文本设置到剪贴板
				uni.setClipboardData({
					data: text,
					success: () => {
						// 可以添加用户友好的提示，例如使用uni.showToast提示复制成功
						uni.showToast({
							title: '复制成功',
							icon: 'success',
							duration: 2000
						});
					}
				});
			},
			processing(item, title) {
				let params = {
					title: title,
					modalshow: true
				}
				this.$emit('processing', item, params)

			},
			getOrderStatus(value) {
				let rut = this.OrderStatusList.find((item) => {
					return item.value == value;
				});
				return rut.name;
			},
			ReviewQuotations(val, title) {
				console.log(val, title)
				let params = {
					data: JSON.stringify({
						pageTitle: title,
						...val
					})
				}
				let url = ''
				if (title === '订单修改') {
					let url = '/pages/socialized-service/order-center/quotation-appointment'
					this.$togo(url, params)
				} else if (title === '订单修改申请') {
					let url = '/pages/socialized-service/order-center/quotation-appointment-edit'
					this.$togo(url, params)
				}

			},


			GotoDetail(e) {
				console.log(e)
				let dataObj = JSON.stringify(e)
				uni.setStorageSync('ProjectOrderDetails', dataObj)
				let params = {
					// data: JSON.stringify(e),
					no: e.executeNo
				}
				let url = "/pages/socialized-service/order-center/order-details"
				this.$togo(url, params)
			},
		}
	}
</script>

<style lang="scss" scoped>
	.orderBox {
		width: 684rpx;
		min-height: 460rpx;
		background-color: #ffffff;
		padding: 12rpx 14rpx 20rpx;
		box-sizing: border-box;
		margin: 0rpx auto;
		margin-top: 30rpx;
		left: 0rpx;
		top: 0rpx;
		width: 684rpx;
		opacity: 1;
		border-radius: 16rpx;
		background: rgba(255, 255, 255, 1);
		box-shadow: 0rpx 0rpx 12rpx rgba(0, 0, 0, 0.05);
		
		&:first-child {
			margin-top: 0;
		}

		.orderTitle {
			height: 42rpx;
			font-size: 26rpx;
			font-weight: bold;
			letter-spacing: 0rpx;
			line-height: 42rpx;
			color: rgba(39, 39, 39, 1);
			text-align: left;
			display: flex;
			justify-content: space-between;

			.one {
				margin-left: 10rpx;
			}

			.two {
				width: calc(100% - 140rpx);
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}

			.three {
				width: 100rpx;
				color: rgba(46, 205, 151, 1);
			}
		}

		.itemBox {
			margin: 10rpx auto 0rpx;
			width: 622rpx;
			min-height: 300rpx;
			opacity: 1;
			border-radius: 10rpx;
			background: rgba(245, 246, 250, 1);
			padding: 12rpx 0rpx 12rpx 18rpx;
			box-sizing: border-box;
			display: flex;
			justify-content: space-between;
			flex-wrap: wrap;

			.itemContent {
				display: flex;
				justify-content: space-between;
				flex-wrap: wrap;
				height: 60rpx;
				line-height: 60rpx;
				font-size: 28rpx;
				font-weight: 400;
				letter-spacing: 0rpx;
				color: rgba(39, 39, 39, 1);

			}

			.itemTitle {
				width: 200rpx;
			}

			.itemValue {
				width: 400rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}
		}

		.btnBox {
			width: 100%;
			display: flex;
			justify-content: flex-end;
			align-items: center;
			color: #ffffff;
			margin-top: 20rpx;
			padding-right: 18rpx;
			font-size: 26rpx;
			box-sizing: border-box;

			.lookClose,
			.lookCompleted,
			.review,
			.del,
			.easy {
				min-width: 110rpx;
				height: 50rpx;
				line-height: 50rpx;
				border-radius: 30rpx;
				padding: 4rpx 12rpx;
				text-align: center;
				margin-left: 8rpx;
				background: linear-gradient(270deg, rgba(136, 172, 255, 1) 0%, rgba(33, 101, 255, 1) 100%);

			}

			.lookCompleted {}

			.del {
				background: linear-gradient(270deg, rgba(249, 170, 170, 1) 0%, rgba(255, 108, 108, 1) 100%);
			}

			.easy {
				background: rgba(0, 0, 0, 0.1);
				color: #999;
				border: 1rpx solid #999;
			}
		}
	}
</style>